// ml:run = $bin > input
#include <iostream>
#include <vector>
#include <algorithm>
#include <unordered_set>
#include <cstring>
#include <ctime>
#include <cstdlib>

int const maxn = 20000;
int father[maxn];
int parent[maxn];

int get_father(int x)
{
    return x == father[x] ? x : (father[x] = get_father(father[x]));
}

std::vector<std::vector<int>> tree;

void add_edge(int u, int v)
{
    tree[u].push_back(v);
    tree[v].push_back(u);
}

void dfs(int u, int f)
{
    parent[u] = f;
    for (auto v : tree[u]) {
        if (v == f) continue;
        dfs(v, u);
    }
}

void print_tree(int n)
{
    tree.clear(); tree.resize(n + 1);
    for (int i = 1; i <= n; i++) father[i] = i;
    for (int i = 1; i < n; i++) {
        int tu = rand() % n + 1;
        int tv = rand() % n + 1;
        do {
            if (get_father(tu) != get_father(tv)) break;
            tu = rand() % n + 1;
            tv = rand() % n + 1;
        } while (true);
        add_edge(tu, tv);
        father[get_father(tu)] = get_father(tv);
    }
    dfs(1, 0);
    for (int i = 2; i <= n; i++)
        std::cout << parent[i] << " ";
    std::cout << "\n";
}

bool vis[1000][1000];

void print_graph(int n, int m)
{
    std::memset(vis, 0, sizeof(vis));
    for (int i = 1; i <= n; i++) vis[i][i] = true;
    for (int i = 0; i < m; i++) {
        int tu = rand() % n + 1;
        int tv = rand() % n + 1;
        do {
            tu = rand() % n + 1;
            tv = rand() % n + 1;
        } while (vis[tu][tv]);
        vis[tu][tv] = vis[tv][tu] = true;
        std::cout << tu << " " << tv << "\n";
    }
}

int main()
{
	std::srand(std::time(0));
	int T = 2;
	std::cout << T << "\n";
	for (int ti = 1; ti <= T; ti++) {
		int n = 5, m = 6;
		std::cout << n << ' ' << m << "\n";
        print_tree(m);
        print_graph(n, m);
        int q = 4;
        int tot = 0;
        std::cout << q << "\n";
        for (int i = 0; i < q; i++) {
            int k = m;
            std::unordered_set<int> us;
            if (tot >= 200000) k = 100;
            if (tot >= 300000) k = 1;
            for (int j = 0; j < k; j++) us.insert(rand() % m + 1);
            std::cout << us.size();
            tot += us.size();
            for (auto j : us) std::cout << " " << j;
            std::cout << "\n";
        }
	}
}

